<template>
    <el-form ref="form" label-width="80px" size="mini" label-position="left" style="margin: 20px">
        <el-form-item label="厂商名称">
            <el-input v-model="row.name"></el-input>
        </el-form-item>
        <el-form-item label="厂商描述">
            <el-input type="textarea" v-model="row.remarks" placeholder="请输入厂商描述"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="submit">保存</el-button>
            <el-button @click="close">取消</el-button>
        </el-form-item>
    </el-form>
</template>
<script>
import C from '@/common/common.js'
import Factory from '@/service/shop/factory.js'
export default {
  name: 'addFactory',
  data () {
    return {
      row: {
        id: 0,
        name: '',
        remarks: ''
      }
    }
  },
  methods: {
    async submit () {
      let res = await Factory.addFactory(this.row)
      if (res) {
        C.closeBrowserWindow(res)
      }
    },
    close () {
      C.closeBrowserWindow()
    }
  },
  mounted: function () {
    let row = C.getDatas()
    if (row && row.id) {
      this.row.id = row.id
      this.row.name = row.name
      this.row.remarks = row.remarks
    }
  }
}
</script>